import commonjs from '@rollup/plugin-commonjs'
import { defineConfig } from 'rollup'
import vue from 'rollup-plugin-vue'
import buble from '@rollup/plugin-buble'
import babel from "@rollup/plugin-babel"
import postcss from 'rollup-plugin-postcss'
import image from '@rollup/plugin-image';
// 自动清理输出目录
import { cleandir } from "rollup-plugin-cleandir";

export default defineConfig({
    input: './src/index.js',
    // 指定输出格式
    output: [
        {
            format: "esm",
            file: "dist/map-pick-position.esm.js",
            exports: 'named',
            globals: {
                vue: 'Vue'
            }
        },
        {
            // node 包
            format: "cjs",
            file: "dist/map-pick-position.cjs.js",
            globals: {
                vue: 'Vue'
            }
        },
        {
            // umd = cjs + commonjs
            format: 'umd',
            file: 'dist/map-pick-position.umd.js',
            // umd 需要提供一个全局的名字 window.mapPickPosition
            name: 'mapPickPosition'
        }
    ],
    // 这2个依赖包，不要打包进库文件， 采用外部依赖，即项目依赖
    external: [
        'Vue',
        'element-ui'
    ],
    plugins: [
        vue({
            // compileTemplate: true, // Explicitly convert template to render function
        }),
        image(),
        cleandir('./dist')
    ]
})